package com.sgg.gulimall_search.web;

import com.sgg.gulimall_common.api.Result;
import com.sgg.gulimall_common.to.ProductUPTo;
import com.sgg.gulimall_search.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/elasticSearch")
public class ElasticSearchController {


    @Autowired
    private IProductService productService;

    @PostMapping("/save")
    public Result elasticSearchIndex(@RequestBody List<ProductUPTo> productUPToList) {
        final int i = productService.insertProduct(productUPToList);
        return Result.success(i);
    }
}
